<template>
    <div class="home-heard">
<div class="left"><h2>后台管理系统</h2></div>
<div class="right">
<li>姓名--{{user.realName}}</li>
<li>性别--{{user.gender}}</li>
<li>用户名--{{user.username}}</li>
<li>昵称--{{user.nickName}}</li>
<li>  
<el-button type="primary" @click="$emit('changexg',user)">编辑信息</el-button>
  <el-button type="danger" @click="tuichu">退出</el-button></li>
</div>
    </div>
</template>

<script>
import {http} from '../../uitl/request'
//import {removeToken} from '../../api/login'
export default {
    name:'home-heard',
    props:['isxg','userinfo'],
    created(){
        this.getuserinfo()
    },
    mounted(){
this.getuserinfo()
//console.log(this.user);
    },
    data(){
        return{
user:{},

        }
    },
    methods:{
 async getuserinfo(){
try{
  const {data:res}=await http.get('/user/findLoginUser')
//this.$store.commit('setuserinfo',res.data)
this.user=res.data
//console.log(this.user);
}catch(err){
  Promise.reject(err)
}},
//退出功能
tuichu(){
window.localStorage.removeItem('jysToken')
this.$router.push('/login')
}
    }
}
</script>
<style scoped>
li{
    list-style: none;
    display: inline-block;
    margin: 0 5px;
  
}
.left {
    display: inline-block;
    float: left;
    width: 300px;
}
.right{
     display: inline-block;
    float: right;
}

</style>
